<template>
  <div>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="addressid" label="地址id" width="180"> </el-table-column>
      <el-table-column prop="addressname" label="地址名称" width="180"> </el-table-column>
      <el-table-column prop="longitude" label="经度" width="180"> </el-table-column>
      <el-table-column prop="latitude" label="纬度"> </el-table-column>
      <el-table-column
      fixed="right"
      label="操作"
      width="120">
      <template slot-scope="scope">
        <el-button
          @click.native.prevent="deleteRow(scope.row)"
          type="text"
          size="small">
          移除
        </el-button>
      </template>
    </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getLocation } from "@/api/location";
import { delLocation } from "@/api/location";
export default {
  data() {
    return {
      tableData: [],
    };
  },
  methods:{
    getlocationlist(){
      getLocation().then((res)=>{
        this.tableData=res.data
      })
    },
    deleteRow(row) {
        delLocation({
          addressid:row.addressid
        }).then((res)=>{
          this.$message({
          message: '删除成功',
          type: 'success'
        });
        this.getlocationlist()
        }).catch((err)=>{
          this.$message({
          message: '警告哦，这是一条警告消息',
          type: 'warning'
        });
        })
      }
  },
  created(){
    this.getlocationlist()
  }
};
</script>

<style>
</style>